<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<title></title>
	<style type="">
		*{
			margin: 0;
			padding: 0;
		}
		.box{
			width: 90%;
			height: 50px;
			background-color: red;
			margin: 0 auto;
			position: sticky;
/*			粘性定位*/
			top: 20px;
/*			元素距离浏览器顶部  等于或小于0  则变为固定定位  反之则变为相对定位*/
			margin-top: 100px;
		}
	</style>
</head>
<body>


	<div class="box"></div>


	<img src="../2.jpg">



	<img src="../01.jpg">



	<img src="../1.jpg">



</body>
</html>